Developer Documentation
PATH  Mac OS X Documentation > Developer Tools > The Objective-C Compiler


Previous | Contents | Next

Hardware Models and Configurations

On Mac OS X, you specify the target architecture you are compiling for with -arch arch_type . The list of acceptable values for arch_type includes anything that arch can return (see arch(3) for more information), Typically, arch_type would be either m68k, i386 ( i386 represents the processor family which includes the i486 and Pentium processors), or sparc .

The option -arch arch_type specifies the target architecture, arch_type , of the operations to be performed. The operations affected by -arch are: preprocessing, precompiling, compiling, assembling, and linking. The specification of multiple architectures results in the production of "fat" output files and the creation of multiple "thin'" intermediate files from each stage. It is an error to use -E , -S , -M , and -MM with multiple architectures as the output form is textual in these cases.

In addition, each of these target machine types can have its own special options, starting with -m , to choose among various hardware models or configurations--for example, 68010 vs 68020, floating coprocessor or none. A single installed version of the compiler can compile for any model or configuration, according to the options specified.

Some configurations of the compiler also support additional special options, usually for compatibility with other compilers on the same platform.

These options are defined by the macro TARGET_SWITCHES in the machine description. The default for the options is also defined by that macro, which enables you to change the defaults.

M680x0 Options

These are the -m options defined for the 68000 series. The default values for these options depends on which style of 68000 was selected when the compiler was configured; the defaults for the most common choices are given below.

-m68881

-m68881

Generate output containing 68881 instructions for floating point. This is the default for most 68020 systems unless -nfp was specified when the compiler was configured.

-m68030

-m68030

Generate output for a 68030. This is the default when the compiler is configured for 68030-based systems.

-m68040

-m68040

Generate output for a 68040. This is the default when the compiler is configured for 68040-based systems.

This option inhibits the use of 68881/68882 instructions that have to be emulated by software on the 68040. If your 68040 does not have code to emulate those instructions, use -m68040 .

-m68020-40

-m68020-40

Generate output for a 68040, without using any of the new instructions. This results in code which can run relatively efficiently on either a 68020/68881 or a 68030 or a 68040. The generated code does use the 68881 instructions that are emulated on the 68040.

-malign-mac68k

-malign-mac68k

In structs that are larger than 2 bytes, the compiler will align its fields on 2-byte boundaries. This is equivalent to - mno-align-power . By default, this option is off.

-malign-power

-malign-power

In structs that are larger than 2 bytes, the compiler will align its fields on 4-byte boundaries. This is equivalent to - mno-align-mac68k . By default, this option is on.

-msoft-float

-msoft-float

Generate output containing library calls for floating point.

-mshort

-mshort

Consider type int to be 16 bits wide, like short int .

-mno-align-mac68k

-mno-align-mac68k

In structs that are larger than 2 bytes, the compiler will align its fields on 4-byte boundaries. This is equivalent to - malign-power . By default, this option is on.

-mno-align-power

-mno-align-power

In structs that are larger than 2 bytes, the compiler will align its fields on 2-byte boundaries. This is equivalent to - malign-mac68k . By default, this option is off.

-mnobitfield

-mnobitfield

Do not use the bit-field instructions.

-mbitfield

-mbitfield

Do use the bit-field instructions. This is the default if you use a configuration designed for a 68020.

-mrtd

-mrtd

Use a different function-calling convention, in which functions that take a fixed number of arguments return with the rtd instruction, which pops their arguments while returning. This saves one instruction in the caller since there is no need to pop the arguments there.

This calling convention is incompatible with the one normally used on Mac OS X and supported UNIX systems, so you cannot use it if you need to call libraries included with the system software.

Also, you must provide function prototypes for all functions that take variable numbers of arguments (including printf ); otherwise incorrect code will be generated for calls to those functions.

In addition, seriously incorrect code will result if you call a function with too many arguments. (Normally, extra arguments are harmlessly ignored.)

SPARC Options

These -m switches are supported on the SPARC:

-mno-app-regs -mapp-regs

-mno-app-regs -mapp-regs

Specify -mapp-regs to generate output using the global registers 2 through 4, which the SPARC SVR4 ABI reserves for applications. This is the default.

To be fully SVR4 ABI compliant at the cost of some performance loss, specify -mno-app-regs . You should compile libraries and system software with this option.

-mfpu -mhard-float

-mfpu -mhard-float

Generate output containing floating point instructions. This is the default.

-mno-fpu -msoft-float

-mno-fpu -msoft-float

Generate output containing library calls for floating point.

-msoft-float changes the calling convention in the output file; therefore, it is only useful if you compile all of a program with this option. In particular, you need to compile libgcc.a , the library that comes with GNU CC, with -msoft-float in order for this to work.

-mhard-quad-float

-mhard-quad-float

Generate output containing quad-word (long double) floating point instructions.

-msoft-quad-float

-msoft-quad-float

Generate output containing library calls for quad-word (long double) floating point instructions. The functions called are those specified in the SPARC ABI. This is the default.

As of this writing, there are no sparc implementations that have hardware support for the quad-word floating point instructions. They all invoke a trap handler for one of these instructions, and then the trap handler emulates the effect of the instruction. Because of the trap handler overhead, this is much slower than calling the ABI library routines. Thus the -msoft-quad-float option is the default.

-mno-epilogue -mepilogue

-mno-epilogue -mepilogue

With -mepilogue (the default), the compiler always emits code for function exit at the end of each function. Any function exit in the middle of the function (such as a return statement in C) will generate a jump to the exit code at the end of the function.

With -mno-epilogue , the compiler tries to emit exit code inline at every function exit.

-mno-flat -mflat

-mno-flat -mflat

With -mflat , the compiler does not generate save/restore instructions and will use a "flat" or single register window calling convention. This model uses %i7 as the frame pointer and is compatible with the normal register window model. Code from either may be intermixed although debugger support is still incomplete. The local registers and the input registers (0-5) are still treated as "call saved" registers and will be saved on the stack as necessary.

With -mno-flat (the default), the compiler emits save/restore instructions (except for leaf functions) and is the normal mode of operation.

-mno-unaligned-doubles -munaligned-doubles

-mno-unaligned-doubles -munaligned-doubles

Assume that doubles have 8 byte alignment. This is the default.

With -munaligned-doubles , GNU CC assumes that doubles have 8 byte alignment only if they are contained in another type, or if they have an absolute address. Otherwise, it assumes they have 4 byte alignment. Specifying this option avoids some rare compatibility problems with code generated by other compilers. It is not the default because it results in a performance loss, especially for floating point code.

-mv8 -msparclite

-mv8 -msparclite

These two options select variations on the SPARC architecture.

By default (unless specifically configured for the Fujitsu SPARClite), GCC generates code for the v7 variant of the SPARC architecture.

-mv8 will give you SPARC v8 code. The only difference from v7 code is that the compiler emits the integer multiply and integer divide instructions which exist in SPARC v8 but not in SPARC v7.

-msparclite will give you SPARClite code. This adds the integer multiply, integer divide step and scan ( ffs ) instructions which exist in SPARClite but not in SPARC v7.

-mcypress -msupersparc

-mcypress -msupersparc

These two options select the processor for which the code is optimised.

With -mcypress (the default), the compiler optimizes code for the Cypress CY7C602 chip, as used in the SparcStation/SparcServer 3xx series. This is also appropriate for the older SparcStation 1, 2, IPX etc.

With -msupersparc the compiler optimizes code for the SuperSparc cpu, as used in the SparcStation 10, 1000 and 2000 series. This flag also enables use of the full SPARC v8 instruction set.

In a future version of GCC, these options will very likely be renamed to -mcpu=cypress and -mcpu=supersparc .

These -m switches are supported in addition to the above on SPARC V9 processors:

-mmedlow

-mmedlow

Generate code for the Medium/Low code model: assume a 32 bit address space. Programs are statically linked, PIC is not supported. Pointers are still 64 bits.

It is very likely that a future version of GCC will rename this option.

-mmedany

-mmedany

Generate code for the Medium/Anywhere code model: assume a 32 bit text segment starting at offset 0, and a 32 bit data segment starting anywhere (determined at link time). Programs are statically linked, PIC is not supported. Pointers are still 64 bits.

It is very likely that a future version of GCC will rename this option.

-mint64

-mint64

Types long and int are 64 bits.

-mlong32

-mlong32

Types long and int are 32 bits.

-mlong64 -mint32

-mlong64 -mint32

Type long is 64 bits, and type int is 32 bits.

-mstack-bias -mno-stack-bias

-mstack-bias -mno-stack-bias

With -mstack-bias , GNU CC assumes that the stack pointer, and frame pointer if present, are offset by -2047 which must be added back when making stack frame references. Otherwise, assume no such offset is present.

Intel 386 Options

These -m options are defined for the i386 family of computers:

-m486 -m386

-m486 -m386

Control whether or not code is optimized for a 486 instead of an 386. Code generated for a 486 will run on a 386 and vice versa.

-mieee-fp -mno-ieee-fp

-mieee-fp -mno-ieee-fp

Control whether or not the compiler uses IEEE floating point comparisons. These handle correctly the case where the result of a comparison is unordered.

-mno-fp-ret-in-387

-mno-fp-ret-in-387

Do not use the FPU registers for return values of functions.

The usual calling convention has functions return values of types float and double in an FPU register, even if there is no FPU. The idea is that the operating system should emulate an FPU.

The option -mno-fp-ret-in-387 causes such values to be returned in ordinary CPU registers instead.

-mno-fancy-math-387

-mno-fancy-math-387

Some 387 emulators do not support the sin , cos and sqrt instructions for the 387. Specify this option to avoid generating those instructions. This option is the default on FreeBSD. As of revision 2.6.1, these instructions are not generated unless you also use the -ffast-math switch.

-malign-double -mno-align-double

-malign-double -mno-align-double

Control whether GNU CC aligns double , long double , and long long variables on a two word boundary or a one word boundary. Aligning double variables on a two word boundary will produce code that runs somewhat faster on a Pentium at the expense of more memory.

-munaligned-text (Not available on Windows NT)

-munaligned-text

Turns off all alignment for instructions. Occasionally this may be interesting if the code size is significant in low-level stuff.

-msvr3-shlib -mno-svr3-shlib

-msvr3-shlib -mno-svr3-shlib

Control whether GNU CC places uninitialized locals into bss or data . -msvr3-shlib places these locals into bss . These options are meaningful only on System V Release 3.

-mno-wide-multiply -mwide-multiply

-mno-wide-multiply -mwide-multiply

Control whether GNU CC uses the mul and imul that produce 64 bit results in eax:edx from 32 bit operands to do long long multiplies and 32-bit division by constants.

-mrtd

-mrtd

Use a different function-calling convention, in which functions that take a fixed number of arguments return with the ret NUM instruction, which pops their arguments while returning. This saves one instruction in the caller since there is no need to pop the arguments there.

You can specify that an individual function is called with this calling sequence with the function attribute stdcall . You can also override the -mrtd option by using the function attribute cdecl . See See Declaring Attributes of Functions

Also, you must provide function prototypes for all functions that take variable numbers of arguments (including printf ); otherwise incorrect code will be generated for calls to those functions.

In addition, seriously incorrect code will result if you call a function with too many arguments. (Normally, extra arguments are harmlessly ignored.)

-mreg-alloc

-mreg-alloc= regs

Control the default allocation order of integer registers. The string regs is a series of letters specifying a register. The supported letters are: a allocate EAX; b allocate EBX; c allocate ECX; d allocate EDX; S allocate ESI; D allocate EDI; B allocate EBP.

-mregparm

-mregparm= num

Control how many registers are used to pass integer arguments. By default, no registers are used to pass arguments, and at most 3 registers can be used. You can control this behavior for a specific function by using the function attribute regparm. See See Declaring Attributes of Functions

-malign-loops

-malign-loops= num

Align loops to a 2 raised to a num byte boundary. If -malign-loops is not specified, the default is 2.

-malign-jumps

-malign-jumps= num

Align instructions that are only jumped to to a 2 raised to a num byte boundary. If -malign-jumps is not specified, the default is 2 if optimizing for a 386, and 4 if optimizing for a 486.

-malign-functions

-malign-functions= num

Align the start of functions to a 2 raised to num byte boundary. If -malign-jumps is not specified, the default is 2 if optimizing for a 386, and 4 if optimizing for a 486.

HPPA Options

These -m options are defined for the HPPA family of computers:

-mpa-risc-1-0

-mpa-risc-1-0

Generate code for a PA 1.0 processor.

-mpa-risc-1-1

-mpa-risc-1-1

Generate code for a PA 1.1 processor.

-mjump-in-delay

-mjump-in-delay

Fill delay slots of function calls with unconditional jump instructions by modifying the return pointer for the function call to be the target of the conditional jump.

-mmillicode-long-calls

-mmillicode-long-calls

Generate code which assumes millicode routines can not be reached by the standard millicode call sequence, linker-generated long-calls, or linker-modified millicode calls. In practice this should only be needed for dynamicly linked executables with extremely large SHLIB_INFO sections.

-mdisable-fpregs

-mdisable-fpregs

Prevent floating point registers from being used in any manner. This is necessary for compiling kernels which perform lazy context switching of floating point registers. If you use this option and attempt to perform floating point operations, the compiler will abort.

-mdisable-indexing

-mdisable-indexing

Prevent the compiler from using indexing address modes. This avoids some rather obscure problems when compiling MIG generated code under MACH.

-mfast-indirect-calls

-mfast-indirect-calls

Generate code which performs faster indirect calls. Such code is suitable for kernels and for static linking. The fast indirect call code will fail miserably if it's part of a dynamically linked executable and in the presense of nested functions.

-mportable-runtime

-mportable-runtime

Use the portable calling conventions proposed by HP for ELF systems.

-mgas

-mgas

Enable the use of assembler directives only GAS understands.

-mschedule

-mschedule= cpu type

Schedule code according to the constraints for the machine type cpu type . The choices for cpu type are 700 for 7N0 machines, 7100 for 7N5 machines, and 7100 for 7N2 machines. 700 is the default for cpu type .

Note the 7100LC scheduling information is incomplete and using 7100LC often leads to bad schedules. For now it's probably best to use 7100 instead of 7100LC for the 7N2 machines.

-msoft-float

-msoft-float

Generate output containing library calls for floating point.

-msoft-float changes the calling convention in the output file; therefore, it is only useful if you compile all of a program with this option. In particular, you need to compile libgcc.a , the library that comes with GNU CC, with -msoft-float in order for this to work.


The Objective-C Compiler

Previous | Contents | Next